package com.magicsoft.share.presenter.my;

import com.magicsoft.share.base.BasePresenter;
import com.magicsoft.share.bean.my.GoldDetail;
import com.magicsoft.share.constant.APIService;
import com.magicsoft.share.constant.SPKey;
import com.magicsoft.share.rx_retrofit_network.location.retrofit.RetrofitUtil;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.LoadingTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.NetWorkTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.SimpleObserver;
import com.magicsoft.share.utils.SPUtils;
import com.magicsoft.share.view.my.IGoldView;

/**
 * Created by lyf on 2017/11/22/022.
 */

public class GoldPresenter extends BasePresenter<IGoldView> {
    public void myAmountDetail(int pageNum,int pageSize) {
        RetrofitUtil.getApi(APIService.class).myAmountDetail(SPUtils.getInstance().getString(SPKey.TOKEN),SPUtils.getInstance().getLong(SPKey.ID),
                pageNum,pageSize)
                .compose(new NetWorkTransformer<GoldDetail>())
                .compose(new LoadingTransformer<GoldDetail>(mContext))
                .subscribe(new SimpleObserver<GoldDetail>(mCompositeDisposable) {
                    @Override
                    public void call(GoldDetail goldDetail) {

                        getView().myAmountDetailSuccess(goldDetail);
                    }

                    @Override
                    public void showErrorMsg(Throwable e, String errorMsg) {
                        super.showErrorMsg(e, errorMsg);
                        getView().myAmountDetailFail();
                    }
                });

    }
}
